package com.cch.android.activity.view;


import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

import com.cch.android.activity.R;
import com.cch.android.util.MyLog;

public class WordAddActivity extends Activity implements OnClickListener{
	
	  
    private Bitmap mBitmap;
    
    private Button effect_close,effect_save;
    
    private EditText wordEdit;
    
	  @Override
	   public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.model_setimage_wordedit_addword);
		Intent intent = getIntent();
		mBitmap = intent.getParcelableExtra("imageBmp");
		initView();
		
	}
	  /**
	   * 初始化数据
	   */
	  private void initView(){
		  
		     effect_close = (Button) findViewById(R.id.setimage1_wordedit_add_colse);
		     effect_save= (Button) findViewById(R.id.setimage1_wordedit_add_save);
		     wordEdit = (EditText)findViewById(R.id.setimage1_wordedit_edit);
		     
		     effect_close.setOnClickListener(this);
		     effect_save.setOnClickListener(this);
	      
	  }
	  @Override
	protected void onDestroy() {
		  if (mBitmap != null) {
				mBitmap.recycle();
				System.gc();
				mBitmap=null;
			}
		super.onDestroy();
		
	}
		@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.setimage1_wordedit_add_colse:
//			backToWordEdit();
			finish();
			break;
		case R.id.setimage1_wordedit_add_save:
			saveToWordEdit();
			break;
		}
		}
		private void backToWordEdit(){
			Intent intent = new Intent();
			intent.setClass(this, WordEditActivity.class);
			startActivity(intent);
			finish();
		}
		/**
		 * 返回wordedit界面
		 */
		private void saveToWordEdit(){
			String editStr = wordEdit.getText().toString();
			MyLog.log("文字内容："+editStr);
			
			Intent intent = new Intent();
			intent.putExtra("addWord", editStr);
			intent.putExtra("imageBmp", mBitmap);
			intent.setClass(this, WordEditActivity.class);
			startActivity(intent);
		}
}
